<!DOCTYPE html>
<html>
<head>
  <!-- 页面 meta -->
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>传智健康</title>
  <meta name="description" content="传智健康">
  <meta name="keywords" content="传智健康">
  <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
  <!-- 引入样式 -->
  <link rel="stylesheet" href="../plugins/elementui/index.css">
  <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="../css/style.css">
  <!-- 样式 -->
  <style>
    .grid-content {
      border-radius: 4px;
      min-height: 40px;
    }
  </style>
</head>
<body class="hold-transition">
<div id="app">
  <!-- 头部 -->
  <div class="content-header">
    <h1>统计分析
      <small>运营数据</small>
    </h1>
    <!-- 面包屑组件 -->
    <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>统计分析</el-breadcrumb-item>
      <el-breadcrumb-item>运营数据</el-breadcrumb-item>
    </el-breadcrumb>
  </div>
  <!-- 主体 -->
  <div class="app-container">
    <!-- 报表页面 -->
    <div class="box" style="height: 900px">
      <!-- 导出报表及标题 -->
      <div class="excelTitle">
        <el-button @click="exportExcel">导出 Excel 报表</el-button>
        运营数据统计
      </div>
      <!-- 报表生成日期 -->
      <div class="excelTime">日期：{{reportData.reportDate}}</div>
      <!-- 表格 -->
      <table class="exceTable" cellspacing="0" cellpadding="0">
        <!-- 会员数据统计标题 -->
        <tr>
          <td colspan="4" class="headBody">会员数据统计</td>
        </tr>
        <!-- 会员数据统计内容 -->
        <tr>
          <td width='20%' class="tabletrBg">新增会员数</td>
          <td width='30%'>{{reportData.todayNewMember}}</td>
          <td width='20%' class="tabletrBg">总会员数</td>
          <td width='30%'>{{reportData.totalMember}}</td>
        </tr>
        <tr>
          <td class="tabletrBg">本周新增会员数</td>
          <td>{{reportData.thisWeekNewMember}}</td>
          <td class="tabletrBg">本月新增会员数</td>
          <td>{{reportData.thisMonthNewMember}}</td>
        </tr>
        <!-- 预约到诊数据统计标题 -->
        <tr>
          <td colspan="4" class="headBody">预约到诊数据统计</td>
        </tr>
        <!-- 预约到诊数据统计内容 -->
        <tr>
          <td class="tabletrBg">今日预约数</td>
          <td>{{reportData.todayOrderNumber}}</td>
          <td class="tabletrBg">今日到诊数</td>
          <td>{{reportData.todayVisitsNumber}}</td>
        </tr>
        <tr>
          <td class="tabletrBg">本周预约数</td>
          <td>{{reportData.thisWeekOrderNumber}}</td>
          <td class="tabletrBg">本周到诊数</td>
          <td>{{reportData.thisWeekVisitsNumber}}</td>
        </tr>
        <tr>
          <td class="tabletrBg">本月预约数</td>
          <td>{{reportData.thisMonthOrderNumber}}</td>
          <td class="tabletrBg">本月到诊数</td>
          <td>{{reportData.thisMonthVisitsNumber}}</td>
        </tr>
        <!-- 热门套餐标题 -->
        <tr>
          <td colspan="4" class="headBody">热门套餐</td>
        </tr>
        <!-- 热门套餐内容 -->
        <tr class="tabletrBg textCenter">
          <td>套餐名称</td>
          <td>预约数量</td>
          <td>占比</td>
          <td>备注</td>
        </tr>
        <tr v-for="s in reportData.hotSetmeal">
          <td>{{s.name}}</td>
          <td>{{s.setmeal_count}}</td>
          <td>{{s.proportion}}</td>
          <td></td>
        </tr>
      </table>
    </div>
  </div>
</div>
</body>

<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    //  定义数据模型，通过 VUE 的数据绑定展示数据
    var vue = new Vue({
        el: '#app',
        data: {
            reportData: {
                reportDate: null,           //  报表日期
                todayNewMember: 0,          //  今日新增会员数
                totalMember: 0,             //  总会员数
                thisWeekNewMember: 0,       //  本周新增会员数
                thisMonthNewMember: 0,      //  本月新增会员数
                todayOrderNumber: 0,        //  今日预约数
                todayVisitsNumber: 0,       //  今日到诊数
                thisWeekOrderNumber: 0,     //  本周预约数
                thisWeekVisitsNumber: 0,    //  本周到诊数
                thisMonthOrderNumber: 0,    //  本月预约数
                thisMonthVisitsNumber: 0,   //  本月到诊数
                hotSetmeal: [
                    {name: '阳光爸妈升级肿瘤12项筛查（男女单人）体检套餐', setmeal_count: 20, proportion: 0.222},
                    {name: '粉红珍爱（女）升级 TM12 项筛查体检套餐', setmeal_count: 20, proportion: 0.222}
                ]                           //  热门套餐数组
            }
        },
        created() {
            //  发送 ajax 请求获取动态数据
            axios.get("/report/getBusinessReportData.do").then((res) => {
                if (res.data.flag) {
                    this.reportData = res.data.data;
                } else {
                    this.$message.error(res.data.message);
                }
            });
        },
        methods: {
            //  导出 Excel 报表
            exportExcel() {
                //  服务器响应输出流
                window.location.href = '/report/exportBusinessReport.do';
            }
        }
    });
</script>
</html>
